package de.tum.in.eist.im.client.Chat.Channel;

import com.google.gwt.core.client.JavaScriptObject;

public class Channel extends JavaScriptObject {
	protected Channel() {}
	
	/**
	 * opens a new Socket for data transaction to the server
	 * @param listener the SocketListener
	 * @return a new Socket
	 */
	public final native Socket open(SocketListener listener) /*-{
		var socket = this.open();
		socket.onopen = function(event) { listener.@de.tum.in.eist.im.client.Chat.Channel.SocketListener::onOpen()();};
	
		socket.onmessage = function(event) { listener.@de.tum.in.eist.im.client.Chat.Channel.SocketListener::onMessage(Ljava/lang/String;)(event.data);};
		return socket;
	}-*/;
}

